﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using IrrKlang;

namespace MuzičkiFeršterker
{
    /// <summary>
    /// Class used to handle information about a single song
    /// </summary>
    public class Song
    {
        private string path = "";
        private string name = "";
        private string artist = "";
        private string title = "";
        private bool isOk = false;
        private string length = "";
        private int intLength = 0;
        private Engine songEngine;

        /// <summary>
        /// Constructor that loads song data
        /// </summary>
        /// <param name="path">Path to the song</param>
        public Song(string path)
        {
            if (File.Exists(path))
            {
                this.path = path;
                this.artist = FetchSongInfo.GetSongArtist(path);
                this.title = FetchSongInfo.GetSongTitle(path);
                this.intLength = FetchSongInfo.GetSongLengthINT(path);
                this.length = FetchSongInfo.GetSongLength(path);
                this.songEngine = EngineTypePairs.GetEngineFromType(path.Substring(path.LastIndexOf('.')));
                isOk = true;
            }
        }

        /// <summary>
        /// Returns file location
        /// </summary>
        public string Path
        {
            get { return path; }
        }

        /// <summary>
        /// Returns song title
        /// </summary>
        public string Title
        {
            get { return title; }
        }

        /// <summary>
        /// Returns song artist
        /// </summary>
        public string Artist
        {
            get { return artist; }
        }

        /// <summary>
        /// Returns "Artist - Title"
        /// </summary>
        public string Name
        {
            get { return artist + " - " + title; }
        }

        /// <summary>
        /// Returns mm:ss time
        /// </summary>
        public string Length
        {
            get { return length; }
        }

        /// <summary>
        /// Returns time in ms
        /// </summary>
        public int LengthInt
        {
            get { return intLength; }
        }

        /// <summary>
        /// Returns true if file was succesfully loaded
        /// </summary>
        public bool IsOk
        {
            get { return isOk; }
        }

        /// <summary>
        /// Returns engine used to play this song
        /// </summary>
        public Engine Engine
        {
            get { return this.songEngine; }
        }
    }
}
